#include "include/undefinedItem.h"

#include <QtGui>

UndefinedItem::UndefinedItem(QWidget *parent)
    : Item(parent)
{
    this->setEnabled(false);

    CreateWidget();
    CreateLayout();
}

void UndefinedItem::CreateWidget()
{
    id = new QLabel(" ", this);
    launch = new QLabel(QString::fromUtf8("启动"), this);
    feedback = new QLabel(QString::fromUtf8("反馈"), this);
    malfunction = new QLabel(QString::fromUtf8("故障"), this);


    id->setAlignment(Qt::AlignCenter);
    launch->setAlignment(Qt::AlignCenter);
    feedback->setAlignment(Qt::AlignCenter);
    malfunction->setAlignment(Qt::AlignCenter);

    this->setStyleSheet("background-color : white");
    launch->setStyleSheet("background-color : gray");
    feedback->setStyleSheet("background-color : gray");
    malfunction->setStyleSheet("background-color : gray");
}

void UndefinedItem::CreateLayout()
{
    QHBoxLayout  *bottomLayout = new QHBoxLayout;
    bottomLayout->addWidget(launch);
    bottomLayout->addWidget(feedback);
    bottomLayout->addWidget(malfunction);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(id);
    mainLayout->addLayout(bottomLayout);

    QSizePolicy policy = sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    setSizePolicy(policy);

    policy = id->sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    id->setSizePolicy(policy);

    policy = launch->sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    launch->setSizePolicy(policy);

    policy = feedback->sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    feedback->setSizePolicy(policy);

    policy = malfunction->sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    malfunction->setSizePolicy(policy);

    setLayout(mainLayout);
}

void UndefinedItem::SwitchToObject()
{

}
